using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class pedestalItem : MonoBehaviour
{
    public List<screwItem> screwItems = new List<screwItem>();

    public Transform Point;
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {

    }
    public screwItem Get()
    {
        if (screwItems.Count == 0) return null;

        var item = screwItems[screwItems.Count - 1];

        screwItems.RemoveAt(screwItems.Count - 1);

        item.SetPos(Point.position, screwItems.Count, this);

        return item;
    }
    public void Set(screwItem item)
    {
        screwItems.Add(item);

        item.SetPos(new Vector3(0, screwItems.Count * 0.3f, 0) + transform.position, screwItems.Count, this);
    }
    public void RemoveAll()
    {
        for (int i = screwItems.Count - 1; i >= 0; i--)
        {
            screwItems[i].DesThis();
        }
        screwItems.Clear();

        My704Job2gameMgr.ins.ChangeNum(5);
    }
    public bool HasColor(screwItem cube)
    {
        if (screwItems.Count == 0)
        {
            return true;
        }
        if (cube.getColor() == screwItems[screwItems.Count - 1].getColor())
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    internal bool has()
    {
        if (screwItems.Count >= 5)
        {
            return false;
        }
        else
        {
            return true;
        }
    }

    internal bool HasDes()
    {
        bool b = true;
        for (int i = 1; i < screwItems.Count; i++)
        {
            if (screwItems[0].getColor() != screwItems[i].getColor())
            {
                b = false;
                break;
            }
        }
        return b;
    }

    internal bool GetCount()
    {
        if (screwItems.Count >= 5)
        {
            return true;
        }
        return false;
    }
}
